#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  04-noAllowed-audadm.sh
# Version	:  1.0
# Date		:  2020/05/29
# Author	:  Lz
# Email		:  lz843723683@gmail.com
# History	:     
#                  Version 1.0, 2020/05/29
# Function	： 测试三权分立 - audadm不被允许的操作
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="三权分立(audadm) - audadm不被允许的操作"

HeadFile_Source_LTFLIB="${LIB_SSHAUTO}"


## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB(){
	return ${TPASS}
}


## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB(){
	return ${TPASS}
}


## TODO ：关闭安全开关
testcase_1(){
	local cmd="sudo setenforce 0"
	SshAuto_CmdLocalAud_LTFLIB "$cmd" "no" "yes"
	TestRetParse_LTFLIB "无法控制安全开关" "False"
}


## TODO ：修改安全开关
testcase_2(){
	local cmd="sudo echo test > /etc/sysconfig/selinux"
	SshAuto_CmdLocalAud_LTFLIB "$cmd" "no" "yes"
	TestRetParse_LTFLIB "无法修改安全开关" "False"
}


## TODO ：查询布尔变量
testcase_3(){
	local cmd="sudo semanage boolean -l"
	SshAuto_CmdLocalAud_LTFLIB "$cmd" "no" "yes"
	TestRetParse_LTFLIB "无法查询布尔变量" "False"
}


## TODO ：管理用户
testcase_4(){
	local cmd="sudo useradd ltftest1"
	SshAuto_CmdLocalAud_LTFLIB "$cmd" "no" "yes"
	TestRetParse_LTFLIB "无法新增用户" "False"
}


## TODO ：用户切换
testcase_5(){
	local cmd="su"
	SshAuto_CmdLocalAud_LTFLIB "$cmd" "no" "yes"
	TestRetParse_LTFLIB "无法用户切换" "False"
}


## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB(){
	testcase_1
	testcase_2
	testcase_3
	testcase_4
	testcase_5

	return $TPASS
}


#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
